package com.hlxj.license.client.controller;

import com.hlxj.license.client.LicenseCheck;
import com.hlxj.license.client.LicenseClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @功能:【LicenseCheckController 】
 * @作者:代守诚
 * @日期:2019/5/22
 * @时间:17:00
 */
@RestController
@RequestMapping("/license")
public class LicenseCheckController {

    @Autowired
    private LicenseClient licenseClient;

    @Autowired
    private LicenseCheck licenseCheck;

    @RequestMapping(value = "/verity", method = RequestMethod.POST)
    public boolean verity(String uuid, String publicKey, HttpServletRequest request, HttpServletResponse response) {
        boolean flag = this.licenseClient.verity(uuid,publicKey);

        return flag;
    }

    @RequestMapping(value = "/check", method = RequestMethod.POST)
    public boolean check(HttpServletRequest request, HttpServletResponse response) {
        boolean flag = this.licenseCheck.checkLisence();

        return flag;
    }

    @RequestMapping(value = "/check/byNet", method = RequestMethod.POST)
    public boolean checkLisenceByNet(HttpServletRequest request, HttpServletResponse response) {
        boolean flag = this.licenseCheck.checkLisenceByNet();

        return flag;
    }
}
